package se.webbzon.oschi01.worldobject.appearance;

import java.awt.Color;

import javax.media.j3d.Bounds;
import javax.media.j3d.Light;
import javax.vecmath.Color3f;

public abstract class LightAppearance3D extends AbstractAppearance3D {
	
	// The light object
	private Light light;
		
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new abstract WorldObjectLightAppearance. **/
	public LightAppearance3D(Light light) {
		this.light = light;
		light.setCapability(Light.ALLOW_COLOR_READ);
		light.setCapability(Light.ALLOW_COLOR_WRITE);
		light.setCapability(Light.ALLOW_STATE_READ);
		light.setCapability(Light.ALLOW_STATE_WRITE);
		getTransformGroup().addChild(light);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns whatever the light is enabled or not. **/
	@Override public boolean getVisible() {
		return light.getEnable();
	}
	
	/** Sets whatever the light is enabled or not. **/
	@Override public void setVisible(boolean enable) {
		light.setEnable(enable);
	}
	
	/** Copies the color of the light to the given Color3f. **/
	public Color getColor() {
		Color3f c = new Color3f();
		light.getColor(c);
		return c.get();
	}
	
	/** Sets the color of the light. **/
	public void setColor(Color color) {
		light.setColor(new Color3f(color));
	}
	
	/** Sets the bound of the light (range). **/
	public void setInfluencingBounds(Bounds bounds) {
		light.setInfluencingBounds(bounds);
	}
	
	/** Returns the bound of the light (range). **/
	public Bounds getInfluencingBounds() {
		return light.getInfluencingBounds();
	}
	
	/*============================================================
	Protected Methods
	============================================================*/
	
	/** Returns the java3d light object associated with this appearance. **/
	protected Light getLight() {
		return light;
	}
	

}
